﻿using DiffuseEnjoyIdle.Core.Attributes;
using DiffuseEnjoyIdle.Core.Enums;
using DiffuseEnjoyIdle.Core.Helper;
using DiffuseEnjoyIdle.Entity.Entitys;
using DiffuseEnjoyIdle.IService;
using DiffuseEnjoyIdle.MessageCenter.RabbitMQ;
using DiffuseEnjoyIdle.Model.Dto;
using Mapster;
using Microsoft.AspNetCore.Mvc;

namespace DiffuseEnjoyIdleUser.Controllers;

[Route("api/[controller]/[action]")]
[ApiController]
public class UserController : ControllerBase
{
    private readonly RabbitMQServer _rabbitMQServer;
    private readonly ILogger<UserController> _logger;
    private readonly IUserService _userService;
    /// <summary>
    /// </summary>
    /// <param name="rabbitMQServer"></param>
    /// <param name="s"></param>
    public UserController(RabbitMQServer rabbitMQServer, ILogger<UserController> logger, IUserService userService)
    {
        _rabbitMQServer = rabbitMQServer;
        _logger=logger;
        _userService=userService;
    }

    [HttpPost] 
    public async Task test(UserDto model)
    {
        
       Parallel.ForEach(Enumerable.Range(1,10),async a=> await _userService.Test());
    }

    [HttpPost]
    [HiddenField]
    public async Task<Users> updates(UserDto model)
    {
      
        return model.Adapt<Users>();
    }
}